package com.ruoyi.law.service.impl;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.law.domain.entity.LawVip;
import com.ruoyi.law.mapper.LawVipMapper;
import com.ruoyi.law.service.ILawVipService;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author code
 * @since 2022-11-24
 */
@Service
public class LawVipServiceImpl extends ServiceImpl<LawVipMapper, LawVip> implements ILawVipService {

    @Override
    public String getNameByVipType(String vipType) {
        if (StrUtil.isBlank(vipType)) {
            return "普通会员";
        }
        LawVip byId = super.getById(Integer.parseInt(vipType));
        return byId == null ? "普通会员" : byId.getName();
    }

    @Override
    public LawVip getByVipType(String vipType) {
        if (StrUtil.isBlank(vipType)) {
            return null;
        }
        return super.getById(Integer.parseInt(vipType));
    }

    @Override
    public String getName(Long serviceId) {
        LawVip byId = super.getById(serviceId);
        return byId == null ? "普通会员" : byId.getName();
    }
}
